package com.ruoyi.web.controller.system;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BAnjuanOld;
import com.ruoyi.system.service.IBAnjuanOldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 旧案卷操作Controller
 * 
 * @author zzr
 * @date 2023-09-16
 */
@RestController
@RequestMapping("/system/old")
public class BAnjuanOldController extends BaseController
{
    @Autowired
    private IBAnjuanOldService bAnjuanOldService;

    /**
     * 查询旧案卷操作列表
     */
    //@PreAuthorize("@ss.hasPermi('system:old:list')")
    @GetMapping("/list")
    public TableDataInfo list(BAnjuanOld bAnjuanOld)
    {
        startPage();
        PageHelper.orderBy("zjh");
        List<BAnjuanOld> list = bAnjuanOldService.selectBAnjuanOldList(bAnjuanOld);
        return getDataTable(list);
    }

    /**
     * 导出旧案卷操作列表
     */
    //@PreAuthorize("@ss.hasPermi('system:old:export')")
    @Log(title = "旧案卷操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BAnjuanOld bAnjuanOld)
    {
        List<BAnjuanOld> list = bAnjuanOldService.selectBAnjuanOldList(bAnjuanOld);
        ExcelUtil<BAnjuanOld> util = new ExcelUtil<BAnjuanOld>(BAnjuanOld.class);
        util.exportExcel(response, list, "旧案卷操作数据");
    }

    /**
     * 获取旧案卷操作详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:old:query')")
    @GetMapping(value = "/{recid}")
    public AjaxResult getInfo(@PathVariable("recid") String recid)
    {
        return success(bAnjuanOldService.selectBAnjuanOldByRecid(recid));
    }

    /**
     * 新增旧案卷操作
     */
    //@PreAuthorize("@ss.hasPermi('system:old:add')")
    @Log(title = "旧案卷操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BAnjuanOld bAnjuanOld)
    {
        return toAjax(bAnjuanOldService.insertBAnjuanOld(bAnjuanOld));
    }

    /**
     * 修改旧案卷操作
     */
    //@PreAuthorize("@ss.hasPermi('system:old:edit')")
    @Log(title = "旧案卷操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BAnjuanOld bAnjuanOld)
    {
        return toAjax(bAnjuanOldService.updateBAnjuanOld(bAnjuanOld));
    }

    /**
     * 删除旧案卷操作
     */
    //@PreAuthorize("@ss.hasPermi('system:old:remove')")
    @Log(title = "旧案卷操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recids}")
    public AjaxResult remove(@PathVariable String[] recids)
    {
        return toAjax(bAnjuanOldService.deleteBAnjuanOldByRecids(recids));
    }
}
